package com.ycsj.goldmedalnewconcept.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.bean.WorkInfo;
import com.ycsj.goldmedalnewconcept.view.RoundImageView;

/**
 * 创建日期：2017/12/6  11:13
 * 描述:
 * 作者:张伟
 */

public class WorkSutdentGvAdapter extends CommonAdapter<WorkInfo.ListBean> {

    private Context context;

    public WorkSutdentGvAdapter(Context context, List<WorkInfo.ListBean> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, final WorkInfo.ListBean listBean) {
        //头像
        RoundImageView lvHead = holder.getView(R.id.lv_head);
        Picasso.with(context).load(listBean.getIcon()).placeholder(R.drawable.header).into(lvHead);
        //名称
        TextView tvName = holder.getView(R.id.tv_name);
        
//        tvName.setTextColor(context.getResources().getColor(R.color.selectcolor));
        
        tvName.setText(listBean.getName());
        
        
        //外层选中
        LinearLayout llOut = holder.getView(R.id.ll_out);

        //状态
        ImageView lvState = holder.getView(R.id.lv_delete);
        //根据选中状态设置选中状态的值
        if (!listBean.isFlag()) {
            lvState.setImageResource(R.drawable.st_select);
        } else {
            lvState.setImageResource(R.drawable.st_normal);
        }
        llOut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listBean.setFlag(!listBean.isFlag());
                notifyDataSetChanged();
            }
        });
    }
}
